package cn.daichi.eruptdemo.entity;

import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.upms.handler.SqlChoiceFetchHandler;

import javax.persistence.Entity;
import javax.persistence.Table;

@Erupt(name = "班级管理")        //erupt类注解
@Table(name = "t_clazz")    //数据库表名
@Entity                      //hibernate实体类标识
public class Clazz extends BaseModel {

    @EruptField(
            views = @View(title = "班级名"),
            edit = @Edit(title = "班级名")
    )
    private String name;

    @EruptField(
            views = @View(title = "年级"),
            edit = @Edit(title = "年级", type = EditType.CHOICE,
                    choiceType = @ChoiceType(vl = {
                            @VL(value = "1", label = "一年级"),
                            @VL(value = "2", label = "二年级"),
                            @VL(value = "3", label = "三年级")
                    })
            ))
    private Long grade;

    @EruptField(
            views = @View(title = "班主任"),
            edit = @Edit(title = "班主任", type = EditType.CHOICE,
                    choiceType = @ChoiceType(fetchHandler = SqlChoiceFetchHandler.class,
                            fetchHandlerParams = "select id,name from t_teacher"
                    )
            ))
    private Long classTeacher;

}
